package com.androwit.engine.mapping.converter.str;

import com.androwit.engine.mapping.Converter;

public class BooleanConverter implements Converter<Boolean, String> {

	protected String trueString = "TRUE";
	protected String falseString = "FALSE";

	public BooleanConverter() {
	}

	public BooleanConverter(String trueString, String falseString) {
		this.trueString = trueString;
		this.falseString = falseString;
	}

	@Override
	public Boolean fromConverted(String value) throws Exception {
		if (value.equalsIgnoreCase(this.trueString))
			return true;
		else if (value.equalsIgnoreCase(this.falseString))
			return false;
		else
			return false;
	}

	@Override
	public String convert(Boolean value) throws Exception {
		if (value = true)
			return this.trueString;
		else
			return this.falseString;
	}

}
